3.1341 \(\int \frac {\tan ^2(c+d x)}{a+b \sin (c+d x)} \, dx\)

Optimal. Leaf size=96 \[ -\frac {2 a^2 \tan ^{-1}\left (\frac {a \tan \left (\frac {1}{2} (c+d x)\right )+b}{\sqrt {a^2-b^2}}\right )}{d \left (a^2-b^2\right )^{3/2}}+\frac {a \tan (c+d x)}{d \left (a^2-b^2\right )}-\frac {b \sec (c+d x)}{d \left (a^2-b^2\right )} \]

[Out]

-2*a^2*arctan((b+a*tan(1/2*d*x+1/2*c))/(a^2-b^2)^(1/2))/(a^2-b^2)^(3/2)/d-b*sec(d*x+c)/(a^2-b^2)/d+a*tan(d*x+c
)/(a^2-b^2)/d

________________________________________________________________________________________

Rubi [A]  time = 0.11, antiderivative size = 96, normalized size of antiderivative = 1.00, number of steps used = 8, number of rules used = 7, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {2727, 3767, 8, 2606, 2660, 618, 204} \[ -\frac {2 a^2 \tan ^{-1}\left (\frac {a \tan \left (\frac {1}{2} (c+d x)\right )+b}{\sqrt {a^2-b^2}}\right )}{d \left (a^2-b^2\right )^{3/2}}+\frac {a \tan (c+d x)}{d \left (a^2-b^2\right )}-\frac {b \sec (c+d x)}{d \left (a^2-b^2\right )} \]

Antiderivative was successfully verified.

[In]

Int[Tan[c + d*x]^2/(a + b*Sin[c + d*x]),x]

[Out]

(-2*a^2*ArcTan[(b + a*Tan[(c + d*x)/2])/Sqrt[a^2 - b^2]])/((a^2 - b^2)^(3/2)*d) - (b*Sec[c + d*x])/((a^2 - b^2
)*d) + (a*Tan[c + d*x])/((a^2 - b^2)*d)

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 204

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> -Simp[ArcTan[(Rt[-b, 2]*x)/Rt[-a, 2]]/(Rt[-a, 2]*Rt[-b, 2]), x] /
; FreeQ[{a, b}, x] && PosQ[a/b] && (LtQ[a, 0] || LtQ[b, 0])

Rule 618

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 2606

Int[((a_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[a/f, Subst[
Int[(a*x)^(m - 1)*(-1 + x^2)^((n - 1)/2), x], x, Sec[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n -
1)/2] &&  !(IntegerQ[m/2] && LtQ[0, m, n + 1])

Rule 2660

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x]}, Dis
t[(2*e)/d, Subst[Int[1/(a + 2*b*e*x + a*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] &&
 NeQ[a^2 - b^2, 0]

Rule 2727

Int[((g_.)*tan[(e_.) + (f_.)*(x_)])^(p_)/((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Dist[a/(a^2 - b^
2), Int[(g*Tan[e + f*x])^p/Sin[e + f*x]^2, x], x] + (-Dist[(b*g)/(a^2 - b^2), Int[(g*Tan[e + f*x])^(p - 1)/Cos
[e + f*x], x], x] - Dist[(a^2*g^2)/(a^2 - b^2), Int[(g*Tan[e + f*x])^(p - 2)/(a + b*Sin[e + f*x]), x], x]) /;
FreeQ[{a, b, e, f, g}, x] && NeQ[a^2 - b^2, 0] && IntegersQ[2*p] && GtQ[p, 1]

Rule 3767

Int[csc[(c_.) + (d_.)*(x_)]^(n_), x_Symbol] :> -Dist[d^(-1), Subst[Int[ExpandIntegrand[(1 + x^2)^(n/2 - 1), x]
, x], x, Cot[c + d*x]], x] /; FreeQ[{c, d}, x] && IGtQ[n/2, 0]

Rubi steps

\begin {align*} \int \frac {\tan ^2(c+d x)}{a+b \sin (c+d x)} \, dx &=\frac {a \int \sec ^2(c+d x) \, dx}{a^2-b^2}-\frac {a^2 \int \frac {1}{a+b \sin (c+d x)} \, dx}{a^2-b^2}-\frac {b \int \sec (c+d x) \tan (c+d x) \, dx}{a^2-b^2}\\ &=-\frac {a \operatorname {Subst}(\int 1 \, dx,x,-\tan (c+d x))}{\left (a^2-b^2\right ) d}-\frac {\left (2 a^2\right ) \operatorname {Subst}\left (\int \frac {1}{a+2 b x+a x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{\left (a^2-b^2\right ) d}-\frac {b \operatorname {Subst}(\int 1 \, dx,x,\sec (c+d x))}{\left (a^2-b^2\right ) d}\\ &=-\frac {b \sec (c+d x)}{\left (a^2-b^2\right ) d}+\frac {a \tan (c+d x)}{\left (a^2-b^2\right ) d}+\frac {\left (4 a^2\right ) \operatorname {Subst}\left (\int \frac {1}{-4 \left (a^2-b^2\right )-x^2} \, dx,x,2 b+2 a \tan \left (\frac {1}{2} (c+d x)\right )\right )}{\left (a^2-b^2\right ) d}\\ &=-\frac {2 a^2 \tan ^{-1}\left (\frac {b+a \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2} d}-\frac {b \sec (c+d x)}{\left (a^2-b^2\right ) d}+\frac {a \tan (c+d x)}{\left (a^2-b^2\right ) d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]  time = 0.19, size = 152, normalized size = 1.58 \[ \frac {\sqrt {a^2-b^2} (a \sin (c+d x)+b \cos (c+d x)-b)-2 a^2 \cos (c+d x) \tan ^{-1}\left (\frac {a \tan \left (\frac {1}{2} (c+d x)\right )+b}{\sqrt {a^2-b^2}}\right )}{d (a-b) (a+b) \sqrt {a^2-b^2} \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right ) \left (\sin \left (\frac {1}{2} (c+d x)\right )+\cos \left (\frac {1}{2} (c+d x)\right )\right )} \]

Antiderivative was successfully verified.

[In]

Integrate[Tan[c + d*x]^2/(a + b*Sin[c + d*x]),x]

[Out]

(-2*a^2*ArcTan[(b + a*Tan[(c + d*x)/2])/Sqrt[a^2 - b^2]]*Cos[c + d*x] + Sqrt[a^2 - b^2]*(-b + b*Cos[c + d*x] +
 a*Sin[c + d*x]))/((a - b)*(a + b)*Sqrt[a^2 - b^2]*d*(Cos[(c + d*x)/2] - Sin[(c + d*x)/2])*(Cos[(c + d*x)/2] +
 Sin[(c + d*x)/2]))

________________________________________________________________________________________

fricas [A]  time = 0.80, size = 305, normalized size = 3.18 \[ \left [\frac {\sqrt {-a^{2} + b^{2}} a^{2} \cos \left (d x + c\right ) \log \left (\frac {{\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, a b \sin \left (d x + c\right ) - a^{2} - b^{2} + 2 \, {\left (a \cos \left (d x + c\right ) \sin \left (d x + c\right ) + b \cos \left (d x + c\right )\right )} \sqrt {-a^{2} + b^{2}}}{b^{2} \cos \left (d x + c\right )^{2} - 2 \, a b \sin \left (d x + c\right ) - a^{2} - b^{2}}\right ) - 2 \, a^{2} b + 2 \, b^{3} + 2 \, {\left (a^{3} - a b^{2}\right )} \sin \left (d x + c\right )}{2 \, {\left (a^{4} - 2 \, a^{2} b^{2} + b^{4}\right )} d \cos \left (d x + c\right )}, \frac {\sqrt {a^{2} - b^{2}} a^{2} \arctan \left (-\frac {a \sin \left (d x + c\right ) + b}{\sqrt {a^{2} - b^{2}} \cos \left (d x + c\right )}\right ) \cos \left (d x + c\right ) - a^{2} b + b^{3} + {\left (a^{3} - a b^{2}\right )} \sin \left (d x + c\right )}{{\left (a^{4} - 2 \, a^{2} b^{2} + b^{4}\right )} d \cos \left (d x + c\right )}\right ] \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(d*x+c)^2*sin(d*x+c)^2/(a+b*sin(d*x+c)),x, algorithm="fricas")

[Out]

[1/2*(sqrt(-a^2 + b^2)*a^2*cos(d*x + c)*log(((2*a^2 - b^2)*cos(d*x + c)^2 - 2*a*b*sin(d*x + c) - a^2 - b^2 + 2
*(a*cos(d*x + c)*sin(d*x + c) + b*cos(d*x + c))*sqrt(-a^2 + b^2))/(b^2*cos(d*x + c)^2 - 2*a*b*sin(d*x + c) - a
^2 - b^2)) - 2*a^2*b + 2*b^3 + 2*(a^3 - a*b^2)*sin(d*x + c))/((a^4 - 2*a^2*b^2 + b^4)*d*cos(d*x + c)), (sqrt(a
^2 - b^2)*a^2*arctan(-(a*sin(d*x + c) + b)/(sqrt(a^2 - b^2)*cos(d*x + c)))*cos(d*x + c) - a^2*b + b^3 + (a^3 -
 a*b^2)*sin(d*x + c))/((a^4 - 2*a^2*b^2 + b^4)*d*cos(d*x + c))]

________________________________________________________________________________________

giac [A]  time = 0.25, size = 107, normalized size = 1.11 \[ -\frac {2 \, {\left (\frac {{\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\relax (a) + \arctan \left (\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + b}{\sqrt {a^{2} - b^{2}}}\right )\right )} a^{2}}{{\left (a^{2} - b^{2}\right )}^{\frac {3}{2}}} + \frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b}{{\left (a^{2} - b^{2}\right )} {\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}}\right )}}{d} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(d*x+c)^2*sin(d*x+c)^2/(a+b*sin(d*x+c)),x, algorithm="giac")

[Out]

-2*((pi*floor(1/2*(d*x + c)/pi + 1/2)*sgn(a) + arctan((a*tan(1/2*d*x + 1/2*c) + b)/sqrt(a^2 - b^2)))*a^2/(a^2
- b^2)^(3/2) + (a*tan(1/2*d*x + 1/2*c) - b)/((a^2 - b^2)*(tan(1/2*d*x + 1/2*c)^2 - 1)))/d

________________________________________________________________________________________

maple [A]  time = 0.38, size = 117, normalized size = 1.22 \[ -\frac {8}{d \left (8 a +8 b \right ) \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}-\frac {8}{d \left (8 a -8 b \right ) \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}-\frac {2 a^{2} \arctan \left (\frac {2 a \tan \left (\frac {d x}{2}+\frac {c}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{d \left (a -b \right ) \left (a +b \right ) \sqrt {a^{2}-b^{2}}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sec(d*x+c)^2*sin(d*x+c)^2/(a+b*sin(d*x+c)),x)

[Out]

-8/d/(8*a+8*b)/(tan(1/2*d*x+1/2*c)-1)-8/d/(8*a-8*b)/(tan(1/2*d*x+1/2*c)+1)-2/d*a^2/(a-b)/(a+b)/(a^2-b^2)^(1/2)
*arctan(1/2*(2*a*tan(1/2*d*x+1/2*c)+2*b)/(a^2-b^2)^(1/2))

________________________________________________________________________________________

maxima [F(-2)]  time = 0.00, size = 0, normalized size = 0.00 \[ \text {Exception raised: ValueError} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(d*x+c)^2*sin(d*x+c)^2/(a+b*sin(d*x+c)),x, algorithm="maxima")

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(4*b^2-4*a^2>0)', see `assume?`
 for more details)Is 4*b^2-4*a^2 positive or negative?

________________________________________________________________________________________

mupad [B]  time = 11.96, size = 148, normalized size = 1.54 \[ \frac {\frac {2\,b}{a^2-b^2}-\frac {2\,a\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{a^2-b^2}}{d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2-1\right )}-\frac {2\,a^2\,\mathrm {atan}\left (\frac {\frac {a^2\,\left (2\,a^2\,b-2\,b^3\right )}{{\left (a+b\right )}^{3/2}\,{\left (a-b\right )}^{3/2}}+\frac {2\,a^3\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (a^2-b^2\right )}{{\left (a+b\right )}^{3/2}\,{\left (a-b\right )}^{3/2}}}{2\,a^2}\right )}{d\,{\left (a+b\right )}^{3/2}\,{\left (a-b\right )}^{3/2}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(c + d*x)^2/(cos(c + d*x)^2*(a + b*sin(c + d*x))),x)

[Out]

((2*b)/(a^2 - b^2) - (2*a*tan(c/2 + (d*x)/2))/(a^2 - b^2))/(d*(tan(c/2 + (d*x)/2)^2 - 1)) - (2*a^2*atan(((a^2*
(2*a^2*b - 2*b^3))/((a + b)^(3/2)*(a - b)^(3/2)) + (2*a^3*tan(c/2 + (d*x)/2)*(a^2 - b^2))/((a + b)^(3/2)*(a -
b)^(3/2)))/(2*a^2)))/(d*(a + b)^(3/2)*(a - b)^(3/2))

________________________________________________________________________________________

sympy [F]  time = 0.00, size = 0, normalized size = 0.00 \[ \int \frac {\sin ^{2}{\left (c + d x \right )} \sec ^{2}{\left (c + d x \right )}}{a + b \sin {\left (c + d x \right )}}\, dx \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sec(d*x+c)**2*sin(d*x+c)**2/(a+b*sin(d*x+c)),x)

[Out]

Integral(sin(c + d*x)**2*sec(c + d*x)**2/(a + b*sin(c + d*x)), x)

________________________________________________________________________________________